<?php

/**
 * 策略模式
 * 传递不同的参数调用不同的策略
 */

interface ITraffic{
    function way();
}

class Walk implements ITraffic {
    public function way(){
        echo "步行".PHP_EOL;
    }
}

class Bus implements ITraffic {
    public function way(){
        echo "公交车".PHP_EOL;
    }
}

class Person{
    public function play(ITraffic $traffic){
        $traffic->way();
    }
}

$p = new Person();
$p->play(new Walk());
$p->play(new Bus());



